home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 7 / 007.d81 / dos #16 < prev    next >
Text File  |  2022-08-26  |  2KB  |  108 lines

  1.       DOS AND DON'TS -- Part 16
  2.       {CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}
  3.  
  4.  
  5.  
  6.   To help clear up a few things about
  7.  
  8. the Block-Allocate command, here is
  9.  
  10. an example.
  11.  
  12.  
  13.  10 OPEN15,8,15    :REM  ERROR/COMM
  14.  20 OPEN2,8,2,"#"  :REM  DATA BUFFER
  15.  30 :
  16.  40 FOR X = 1 to 10:REM  WRITE TO BUFF
  17.  50 PRINT#2, "THIS IS DATA"
  18.  60 NEXT X
  19.  70 :
  20.  80 TR=10 : SE=15  :REM TRACK/SECTOR
  21.  90 :
  22. 100 PRINT#15,"B-A:"0;TR;SE
  23. 110 INPUT#15,ER,ER$,NT,NS
  24. 120 :
  25. 130 IF ER=65 THEN TR=NT:SE=NS:GOTO 100
  26. 140 :
  27. 150 PRINT"We can put the data at:"
  28. 160 PRINT"TRACK  # :";TR
  29. 170 PRINT"SECTOR # :";SE
  30. 180 :
  31. 190 CLOSE2:CLOSE15
  32. 200 END
  33.  
  34.  
  35.   First of all, this program does NOT
  36.  
  37. write anything to the disk.  All it
  38.  
  39. does is put data into the buffer and
  40.  
  41. FIND a place to put it.  To actually
  42.  
  43. write data to the disk, we use the
  44.  
  45. USER - TWO command.  The U2 command
  46.  
  47. tells the disk-drive to 'put all that
  48.  
  49. stuff in the buffer onto the disk
  50.  
  51. starting at TRACK xx , SECTOR yy'.
  52.  
  53.   If we modify our above program, we
  54.  
  55. can get our data written to the disk.
  56.  
  57.  
  58.  10 OPEN15,8,15
  59.  20 OPEN2,8,2,"#"
  60.  30 :
  61.  40 FOR X = 1 TO 10
  62.  50 PRINT#2,"THIS IS DATA"
  63.  60 NEXT X
  64.  70 :
  65.  80 TR=10 : SE=15
  66.  90 :
  67. 100 PRINT#15,"B-A:"0;TR;SE
  68. 110 INPUT#15,ER,ER$,NT,NS
  69. 120 :
  70. 130 IF ER=65 THEN TR=NT:SE=NS:GOTO100
  71. 140 :
  72. 150 PRINT"WE CAN PUT THE DATA AT:"
  73. 160 PRINT"TRACK   #";TR
  74. 170 PRINT"SECTOR  #";SE
  75. 180 :
  76. 190 REM   SO LET'S WRITE THE DATA
  77. 200 PRINT#15,"U2:"2;0;TR;SE
  78. 210 :
  79. 220 REM THIS WRITES THE DATA IN BUFFER
  80. 230 REM NUMBER 2, ONTO DRIVE 0,
  81. 240 REM AT TRACK 'TR' AND
  82. 250 REM SECTOR 'SE'.
  83. 260 :
  84. 270 CLOSE2:CLOSE15
  85. 280 END
  86.  
  87.  
  88.   Well, now we know how to get data
  89.  
  90. written to the disk by way of the
  91.  
  92. U2 command.  One thing you should
  93.  
  94. notice is that whatever buffer we
  95.  
  96. put our data into (via PRINT#2 in line
  97.  
  98. 50), is the buffer we want to tell
  99.  
  100. the U2 command to get the data from.
  101.  
  102. Hence there is a '2' in the line with
  103.  
  104. the U2 command.
  105.  
  106.  
  107. ------- continued in PART 17 ---------
  108.